package com.swallow.auth.domain.auth.model;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.stream.Stream;

/**
 * @author: yangjie.deng@resico.cn
 * @since: 2024-05-13 10:55:31
 * @version: v1.0.0
 * @describe:
 */
@Getter
public enum SmsType {
    REGISTER_SMS_TYPE("REGISTER", SmsTemplateCode.REGISTER_SMS_TEMPLATE_CODE, "注册短信")

    ;
    private final String value;
    private final String templateCode;
    private final String name;

    SmsType(String value, String templateCode, String name) {
        this.value = value;
        this.templateCode = templateCode;
        this.name = name;
    }


    public static SmsType findSmsByType(String value) {
       return Stream.of(values())
                    .filter(val -> StringUtils.equals(val.getValue(), value))
                    .findFirst()
                    .orElseThrow(() -> new RuntimeException("未找到对应value信息"));
    }
}
